package Day25;

public class Text1 {
    public static void main(String[] args) {
        Person[] p = new Person[3];
        p[0] = new Person("小周",24,"扫地");
        p[1] = new Person("小玉",54,"拖地");
        p[2] = new Person("夏红",65,"擦窗子");
        for(int i =0 ; i < p.length; i++){
            System.out.println(p[i]);
        }

        for(int i = 0; i < p.length -1; i++){
            Person temp = null;
            for(int j = 0; j < p.length -1 -i; j++){
                if(p[j].getAge() < p[j + 1].getAge()){
                    temp = p[j];
                    p[j] = p[j +1];
                    p[j + 1] = temp;
                }
            }
        }
        System.out.println("========================");
        for(int i = 0; i < p.length; i++){
            System.out.println(p[i]);
        }

    }
}

class Person{
    private String name;
    private int age;
    private String job;

    public Person(String name, int age, String job) {
        this.name = name;
        this.age = age;
        this.job = job;
    }

    public Person() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }
    public String toString(){
        return "Person{ name = " +name + ", age = " + age + ", job = " + job +" }";
    }
}

